<%inherit file="admin_base.html"/>

<%block name="main">

<div class="ly-item-body">
  <div class="row-fluid text-center ly-item-body">
    <div class="span3">
      <div class="ly-box">
        <img src="${ theme_url('img/user_group.png') }"/>
        <h2>${ _("User") }</h2>
        <p><a href="${ reverse_url('admin:user') }"><span class="ly-count">${ TOTAL_USER }</span></a></p>
      </div>
    </div>

    <div class="span3">
      <div class="ly-box">
        <img src="${ theme_url('img/virtual_appliance.png') }"/>
        <h2>${ _("Appliance") }</h2>
        <p><a href="${ reverse_url('admin:appliance') }"><span class="ly-count">${ TOTAL_APPLIANCE }</span></a></p>
      </div>
    </div>

    <div class="span3">
      <div class="ly-box">
        <img src="${ theme_url('img/virtual_machine.png') }"/>
        <h2>${ _("Instance") }</h2>
        <p><a href="${ reverse_url('admin:instance') }"><span class="ly-count">${ TOTAL_INSTANCE }</span></a></p>
      </div>
    </div>

    <div class="span3">
      <div class="ly-box">
        <img src="${ theme_url('img/compute_node.png') }"/>
        <h2>${ _("Node") }</h2>
        <p><a href="${ reverse_url('admin:node') }"><span class="ly-count">${ TOTAL_NODE }</span></a></p>
      </div>
    </div>
  </div>

</div>

<div class="row-fluid ly-item-body">
  % if TOTAL_CPU or TOTAL_MEMORY:
  <div class="span6 admin-pie1" id="admin-cpu-pie"></div>
  <div class="span6 admin-pie1" id="admin-mem-pie"></div>
  <script src="${ static_url('third/highcharts/highcharts.js') }"></script>
  <script type="text/javascript">
    draw_used({
        container: '#admin-cpu-pie',
        title: '${ _("CPU USED INFO") }',
        subtitle: '${ _("Total") } : ${ TOTAL_CPU } ${ _("core") }',
        series_name: '${ _("Percentage") }',
        used_text: '${ _("Used") }<br/>${ USED_CPU } ${ _("core") }',
        unused_text: '${ _("Unused") }<br/>${ TOTAL_CPU - USED_CPU } ${ _("core") }',
        used: ${ USED_CPU },
        total: ${ TOTAL_CPU },
    });

    draw_used({
        container: '#admin-mem-pie',
        title: '${ _("MOMORY USED INFO") }',
        subtitle: '${ _("Total") } : ${ human_size(TOTAL_MEMORY * 1000) }',
        series_name: '${ _("Percentage") }',
        used_text: '${ _("Used") }<br/>${ human_size(USED_MEMORY * 1024) }',
        unused_text: '${ _("Unused") }<br/>${ human_size((TOTAL_MEMORY - USED_MEMORY) * 1024) }',
        used: ${ USED_MEMORY },
        total: ${ TOTAL_MEMORY },
    });
  </script>

  % else:
  <div class="hero-unit">
    <p class="text-warning">${ _("Important: you have not any resources yet. please check you compute nodes.") } <a href="${ reverse_url('admin:node') }">${ _("Node List") }</a></p>
  </div>
  % endif
</div>

<div class="ly-item-title">${ _("Last 10 users") }
  <a href="${ reverse_url('admin:user') }">${ _("View All User") }</a></div>

<div class="ly-item-body">
  <table class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>${ _("ID") }</th>
        <th>${ _("Name") }</th>
        <th>${ _("Groups") }</th>
        <th>${ _("Instance") }</th>
        <th>${ _("Email") }</th>
        <th>${ _("Last Active") }</th>
      </tr>
    </thead>
    <tbody>
      % for U in NEW_USER_LIST:
      <tr>
        <td>${ U.id }</td>
        <td><a class="action" href="${ reverse_url('admin:user:view') }?id=${ U.id }">${ U.username }</a></td>
        <td>
          % for G in U.groups:
          <a href="${ reverse_url('admin:group') }?id=${ G.id }">${ G.name }</a>
          % endfor
        </td>
        <td>
          % if U.instances:
          <a href="${ reverse_url('admin:instance') }?uid=${ U.id }">${ len(U.instances) }</a>
          % endif
        </td>
        <td>${ U.email }</td>
        <td>${ htime(U.last_active) }</td>
      </tr>
      % endfor
    </tbody>
  </table>
</div>


<div class="ly-item-title">${ _("Last 10 jobs") }
  <a href="${ reverse_url('admin:job') }">${ _("View All Job") }</a></div>

<div class="ly-item-body">
  <table class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>${ _("ID") }</th>
        <th>${ _("User") }</th>
        <th>${ _("Status") }</th>
        <th>${ _("Target Type") }</th>
        <th>${ _("Target ID") }</th>
        <th>${ _("Action") }</th>
        <th>${ _("Completed") }</th>
      </tr>
    </thead>
    <tbody>
      % for j in NEW_JOB_LIST:
      <tr>
        <td>${ j.id }</td>
        <td>
          % if j.user_id:
          <a href="${ reverse_url('admin:user:view') }?id=${ j.user_id }">${ j.user.username }</a>
          % endif
        </td>
        <td>${ j.status_icon } ${ _(j.status_string) }</td>
        <td>${ j.target_name }</td>
        <td>${ j.target_url }</td>
        <td>${ j.action_string }</td>
        <td>${ htime(j.ended) }</td>
      </tr>
      % endfor
    </tbody>
  </table>
</div>

</%block>
